package ru.nsu.fit.endpoint;

import ru.nsu.fit.shared.config_manager.ConfigManager;
import ru.nsu.fit.shared.engine.AskJoeEngine;
import ru.nsu.fit.ws.authentication.AuthenticationImpl;
import ru.nsu.fit.ws.get_questions.QuestionsGetterImpl;
import ru.nsu.fit.ws.get_questions_stat.QuestionsStatGetterImpl;
import ru.nsu.fit.ws.get_user_stat.UserStatImpl;
import ru.nsu.fit.ws.registration.RegistrationImpl;
import ru.nsu.fit.ws.send_answer.AnswerSenderImpl;
import ru.nsu.fit.ws.send_question.QuestionSenderImpl;
import ru.nsu.fit.ws.server_info.ServerInfoImpl;

import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.util.Set;

/**
 * Author: Timur Zolotuhin (tzolotuhin@gmail.com)
 * Date: 12.10.12
 * Time: 22:40
 */

//Endpoint publisher
final class AskJoePublisher {
    private AskJoePublisher() {}

    public static void main(final String[] args) {
        // Load config.ini
        ConfigManager.getInstance();

        // run engine
        Thread t = new Thread(new AskJoeEngine());
        t.setDaemon(true);
        t.start();

        // Publish services
        Endpoint.publish("http://localhost:8080/ws/server_info", new ServerInfoImpl());
        Endpoint.publish("http://localhost:8080/ws/registration", new RegistrationImpl());
        Endpoint.publish("http://localhost:8080/ws/authentication", new AuthenticationImpl());
        Endpoint.publish("http://localhost:8080/ws/send_question", new QuestionSenderImpl());
        Endpoint.publish("http://localhost:8080/ws/send_answer", new AnswerSenderImpl());
        Endpoint.publish("http://localhost:8080/ws/get_user_stat", new UserStatImpl());
        Endpoint.publish("http://localhost:8080/ws/get_questions", new QuestionsGetterImpl());
        Endpoint.publish("http://localhost:8080/ws/get_questions_stat",
                new QuestionsStatGetterImpl());
    }
}
